#pragma once

#include <stdlib.h>
#include "ISymtable.h"
#include "StringTabV0.h"
#include "Helper.h"


class SymtabEntry
{
    Information info;
    SymtabEntry* prev;

public:
    SymtabEntry(Information info);
    ~SymtabEntry();

    SymtabEntry* getPrev();
    void setPrev(SymtabEntry* prev);
    Information& getInfo();
    void setInfo(Information info);
};

class SymtableV0 : public ISymtable
{
    IStringTab* tab;
    SymtabEntry** map;
    int* entriesPerHash;
    char lastChar;

    virtual void initKeywords();
    virtual void putKeyword(const char * const keyword, size_t len);
    virtual int lookup(Hash hash, Lexem lexem);
    virtual SymtabEntry* getEntryByOffset(int offset, Hash hash);

public://vars
    static const size_t HASH_CNT;

	SymtableV0();
	virtual ~SymtableV0();

    virtual Hash calculateHash(Lexem lexem);
    
    //inheritance from ISymtable
    virtual void        putChar(char c);
    virtual Key         mkToken(TType& type);
    virtual Information& lookup(Key key);
    virtual SymtabEntry* getSymtabEntry(Key key);
};
